package com.leorui.schoollife.entity

import net.sf.json.JSONArray
import net.sf.json.JSONObject


class ListNoteResponse {
    var status: Int? = null
    var msg: String? = null
    var pageSize: Int? = null
    var currentPage: Int? = null
    var haveMore: Boolean? = null
    var noteList: List<NoteEntity?>? = null

    constructor() : this(null, null)
    constructor(status: Int?, msg: String?) : this(status, msg, null, null, null, null)

    constructor(status: Int?, msg: String?, pageSize: Int?, currentPage: Int?, haveMore: Boolean?, noteList: List<NoteEntity?>?) {
        this.status = status
        this.msg = msg
        this.pageSize = pageSize
        this.currentPage = currentPage
        this.haveMore = haveMore
        this.noteList = noteList
    }

    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["status"] = status
        json["msg"] = msg
        json["page_size"] = pageSize
        json["current_page"] = currentPage
        json["have_more"] = haveMore
        val list = JSONArray()
        noteList?.forEach {
            list.add(it?.toMap())
        }
        json["note_list"] = list.toList()
        return json.toMap()
    }
}

class SingleNoteResponse {
    var status: Int? = null
    var msg: String? = null
    var note: NoteEntity? = null

    constructor() : this(null, null, null)


    constructor(status: Int?, msg: String?, note: NoteEntity?) {
        this.status = status
        this.msg = msg
        this.note = note
    }

    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["status"] = status
        json["msg"] = msg
        json["note"] = note?.toMap()
        return json.toMap()
    }
}

class NoteEntity {
    var noteId: String? = null // 备忘录id
    var title: String? = null // 备忘录标题
    var msg: String? = null // 备忘录信息
    var recordStartTime: String? = null // 备忘录初次添加时间
    var lastEditTime: String? = null // 上一次编辑时间
    var account: String? = null
    fun toMap(): Map<Any?, Any?> {
        val json = JSONObject()
        json["note_id"] = noteId
        json["title"] = title
        json["msg"] = msg
        json["record_start_time"] = recordStartTime
        json["last_edit_time"] = lastEditTime
        json["account"] = account
        return json.toMap()
    }
}